package cn.csc.module.search.dal.dataobject.spu;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.math.BigDecimal;
import java.math.BigInteger;
import java.time.LocalDateTime;

/**
 * SPU实体类
 * 注意SpuDO的Java类型必须与ES中索引Mapping的类型一致，否则会报
 * @author liuchuang
 * @version 1.0
 * @modify
 * @since 2025/3/17 14:07
 */
@Setter
@Getter
@ToString
@Document(indexName = "spu_index")
public class SpuDO {

    @Id
    private BigInteger id;

    /**
     * 品牌ID
     */
    @Field(name = "brand_id", type = FieldType.Long)
    private BigInteger brandId;
    /**
     * 分类ID
     */
    @Field(name = "category_id", type = FieldType.Long)
    private BigInteger categoryId;
    /**
     * 类目名称
     */
    @Field(name = "category_name", type = FieldType.Text, analyzer = "ik_smart")  // 使用IK分词器
    private String categoryName;
    /**
     * 分类等级所有
     */
    @Field(name = "category_level", type = FieldType.Keyword)
    private String categoryLevel;
    /**
     * 店铺分类ID
     */
    @Field(name = "shop_category_id", type = FieldType.Long)
    private BigInteger shopCategoryId;
    /**
     * 店铺id
     */
    @Field(name = "shop_id", type = FieldType.Long)
    private BigInteger shopId;
    /**
     * 店铺名称
     */
    @Field(name = "shop_name", type = FieldType.Keyword)
    private String shopName;
    /**
     * 商品名称
     */
    @Field(name = "name", type = FieldType.Text, analyzer = "ik_smart")  // 使用IK分词器
    private String name;
    /**
     * 授权手机号
     */
    @Field(type = FieldType.Keyword)
    private String phone;
    /**
     * 卖点
     */
    @Field(name = "selling_point", type = FieldType.Text, analyzer = "ik_smart")
    private String sellingPoint;
    /**
     * 商品介绍主图
     */
    @Field(name = "main_img_url", type = FieldType.Keyword)
    private String mainImgUrl;
    /**
     * 商品图片 多个图片逗号分隔
     */
    @Field(name = "img_urls", type = FieldType.Keyword)
    private String imgUrls;
    /**
     * 商品视频
     */
    private String video;
    /**
     * 售价，整数方式保存
     */
    @Field(name = "price_fee", type = FieldType.Scaled_Float)
    private BigDecimal priceFee;

    /**
     * 市场价，整数方式保存
     */
    @Field(name = "market_price_fee", type = FieldType.Scaled_Float)
    private BigDecimal marketPriceFee;

    /**
     * 企业购售价
     */
    @Field(name = "shop_price_fee", type = FieldType.Scaled_Float)
    private BigDecimal shopPriceFee;
    /**
     * 企业购市场价
     */
    @Field(name = "shop_market_price_fee", type = FieldType.Scaled_Float)
    private BigDecimal shopMarketPriceFee;
    /**
     * 基本单位
     */
    private String unit;

    /**
     * 是否企业购 0：否  1：是
     */
    @Field(name = "has_shop", type = FieldType.Short)
    private Integer hasShop;

    /**
     * 审核状态 0：本地  5:待审核  10:审核通过  15:审核不通过
     */
    @Field(name = "verify_status", type = FieldType.Integer)
    private Integer verifyStatus;
    /**
     * 状态 -1:删除, 0:下架, 1:上架
     */
    @Field(type = FieldType.Integer)
    private Integer status;
    /**
     * sku是否含有图片 0无 1有
     */
    @Field(name = "has_sku_img", type = FieldType.Short)
    private Integer hasSkuImg;
    /**
     * 序号
     */
    @Field(type = FieldType.Integer)
    private Integer seq;
    /**
     * 审核时间
     */
    @Field(name = "verify_time", type = FieldType.Date, format = DateFormat.date_time_no_millis)
    private LocalDateTime verifyTime;
    /**
     * 上架提交待审核时间
     */
    @Field(name = "online_time", type = FieldType.Date, format = DateFormat.date_time_no_millis)
    private LocalDateTime onlineTime;

    /**
     * 运费
     */
    @Field(name = "freight_fee", type = FieldType.Scaled_Float)
    private BigDecimal freightFee;

    /**
     * 运费备注
     */
    @Field(name = "freight_remark", type = FieldType.Keyword)
    private String freightRemark;

    /**
     * 商品类型(10普通，20选品)
     */
    @Field(type = FieldType.Integer)
    private Integer type;
    /**
     * 分数10普通，20选品)
     */
    @Field(type = FieldType.Long)
    private BigInteger fraction;

    @Field(type = FieldType.Keyword)
    private String creator;

    @Field(name = "create_time", type = FieldType.Date, format = DateFormat.date_time_no_millis)
    private LocalDateTime createTime;

    @Field(type = FieldType.Keyword)
    private String updater;

    @Field(name = "update_time", type = FieldType.Date, format = DateFormat.date_time_no_millis)
    private LocalDateTime updateTime;


    @Field(name = "tenant_id", type = FieldType.Long)
    private BigInteger tenantId;

}
